package pl.enigmatic.validation.util;

import pl.enigmatic.validation.SimpleValidator;


public abstract class StringValidator implements SimpleValidator<String> {

	public static final SimpleValidator<String> NOT_NULL = new NotNull<String>();

	public static final StringValidator LOWERCASE = new StringValidator() {

		@Override
		public boolean isValueValid(final String val) {
			return NOT_NULL.isValueValid(val) && val.equals(val.toLowerCase());
		}
	};

	public static final StringValidator UPPERCASE = new StringValidator() {

		@Override
		public boolean isValueValid(final String val) {
			return NOT_NULL.isValueValid(val) && val.equals(val.toUpperCase());
		}
	};

	public static final StringValidator MAX_LENGTH(final int len) {
		return new StringValidator() {

			@Override
			public boolean isValueValid(final String val) {
				return NOT_NULL.isValueValid(val) && val.length() <= len;
			}
		};
	}

	private StringValidator() {}
}
